﻿using CatSimulator.Models;
using Loli.Library.Hook;
using Loli.Library.Util;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace CatSimulator
{
    public partial class StepKeyRate : FormBase
    {
        private GameConfig _Config = DataFactory.GetGameConfig();

        public StepKeyRate()
        {
            InitializeComponent();
        }



        private void butStartTest_Click(object sender, EventArgs e)
        {

            ////新建进程

            //Task task = new Task(() =>
            //{

            //    if (_Config.GameHandle == IntPtr.Zero)
            //    {
            //        _Config.GameHandle = WinAPI.FindWindow(null, _Config.GameTitle);
            //    }
            //    Thread.Sleep(1000);



            //    //激活窗体
            //    WinAPI.SetForegroundWindow(_Config.GameHandle);


            //    Image<Bgr, byte> source = new Image<Bgr, byte>(ScreenCapturer.Capture(_Config.GameHandle));

            //    //获取小地图区域
            //    Image<Bgr, byte> template = new Image<Bgr, byte>(@"Datas\Point.bin");

            //    //获取位置
            //    List<Point> list = EmguCV.TemplateMatching(source, template, 0.85);
            //    Point onePoint = list.FirstOrDefault();

            //    this.Invoke((UpdateInterface)delegate()
            //    {
            //        pictureBox1.Image = source.Bitmap;
            //    });
            //    //按键1秒钟
            //    KeyboardMouseOperator.KeyDown(Keys.Left);
            //    Thread.Sleep(1000);
            //    KeyboardMouseOperator.KeyUp(Keys.Left);
            //    Thread.Sleep(5000);


            //    Image<Bgr, byte> source2 = new Image<Bgr, byte>(ScreenCapturer.Capture(_Config.GameHandle));
            //    List<Point> list2 = EmguCV.TemplateMatching(source2, template, 0.85);
            //    Point twoPoint = list2.FirstOrDefault();

            //  //-0.011

            //    this.Invoke((UpdateInterface)delegate()
            //    {
            //        pictureBox2.Image = source2.Bitmap;
            //        tbRank.Text = (twoPoint.X - onePoint.X) / 1000d + "距离";
            //    });
            //});

            //task.Start();
        }
    }
}